package
{
	import flash.events.MouseEvent;
	
	import models.vo.UserVO;
	
	import org.dexter.sendDexterEvent;
	
	import views.P2PVideo;


	public class SmallUI extends SmallVideoBackground
	{
		public var p2pVideo:P2PVideo = new P2PVideo(160,120);
		public var index:int;
		public function SmallUI(i:int)
		{
			super();
			index = i;
			p2pVideo.x = videoBack.x;
			p2pVideo.y = videoBack.y;
			publishLight.gotoAndStop(1);
			closeBn.visible = false;
			closeBn.addEventListener(MouseEvent.CLICK,onStopPublish);
			addChild(p2pVideo);
		}
		private function onStopPublish(event:MouseEvent):void{
			sendDexterEvent("stopPublish",index);
		}
		public function setUser(user:UserVO):void{
			p2pVideo.setUser(user);
			if(user){
				videoName.text = user.name;
				if(UserVO.self.role == UserVO.ADMIN){
					closeBn.visible = true;
				}
				publishLight.gotoAndStop(2);
				sendDexterEvent("callJs",'notification',{msg:videoName.text+"的视频已经停靠",showType:'slide'});
			}else{
				closeBn.visible = false;
				sendDexterEvent("callJs",'notification',{msg:videoName.text+"的视频已经停止发布",showType:'slide'});
				videoName.text = "";
				publishLight.gotoAndStop(1);
			}
		}
	}
}